package cn.flying.cloud.message.core.enums;

import java.util.Arrays;
import java.util.Optional;

import cn.flying.cloud.base.common.enums.BaseEnumInfo;

/**
 * 消息服务厂商枚举
 *
 * @author: admin
 * @date: 2025年03月27日 16:20
 * @version: 1.0
 */
public enum SmsProviderEnum implements BaseEnumInfo {
    ALIYUN("aliyun", "阿里云"),
    TENCENT("tencent", "腾讯云"),
    QINIU("qiniu", "七牛云"),
    ;

    private final String code;
    private final String desc;

    SmsProviderEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 获取枚举码值
     *
     * @return
     */
    @Override
    public String getCode() {
        return this.code;
    }

    /**
     * 获取枚举描述
     *
     * @return
     */
    @Override
    public String getDesc() {
        return this.desc;
    }

    public static SmsProviderEnum getByCode(String code) {
        SmsProviderEnum[] values = SmsProviderEnum.values();
        Optional<SmsProviderEnum> optional = Arrays.stream(values).filter(v -> code.equals(v.getCode())).findFirst();
        return optional.orElse(null);
    }
}
